package com.custom.tag;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;

/**
 * @Author limin
 * @Date 2018/9/20
 * @Description
 */
public class ContentReplaceTag extends BodyTagSupport{

    private Integer version;

    @Override
    public int doStartTag() throws JspException {

        HttpServletRequest httpServletRequest = (HttpServletRequest)pageContext.getRequest();

        //判断是否有权限访问
        System.out.println(version);
        if (version.equals(400)) {
            //允许访问标签body
            return BodyTagSupport.EVAL_BODY_INCLUDE;// 返回此则执行标签body中内容，SKIP_BODY则不执行
        } else {
            return BodyTagSupport.SKIP_BODY;
        }
    }

    public Integer getVersion() {
        return version;
    }

    public void setVersion(Integer version) {
        this.version = version;
    }
}
